﻿#pragma once

#include "../../Server/Settings.h"
#include "../../Server/MirEnvir/Envir.h"
#include "../../Server/MirDatabase/MonsterInfo.h"
#include <string>
#include <vector>
#include <limits>
#include <any>

using namespace Server::MirDatabase;
using namespace Server::MirEnvir;

namespace Server
{
    class MonsterInfoForm : public System::Windows::Forms::Form
    {
    public:
        std::string MonsterListPath = Path::Combine(Settings::ExportPath, "MonsterList.txt");

        virtual ~MonsterInfoForm()
        {
            delete components;
            delete tabControl1;
            delete tabPage1;
            delete MonsterInfoPanel;
            delete CanTameCheckBox;
            delete CanPushCheckBox;
            delete ViewRangeTextBox;
            delete label33;
            delete LightTextBox;
            delete label9;
            delete ExperienceTextBox;
            delete label7;
            delete MSpeedTextBox;
            delete label6;
            delete ASpeedTextBox;
            delete label5;
            delete LevelTextBox;
            delete label4;
            delete EffectTextBox;
            delete label2;
            delete AITextBox;
            delete label8;
            delete AgilityTextBox;
            delete label26;
            delete AccuracyTextBox;
            delete label27;
            delete HPTextBox;
            delete label25;
            delete MaxSCTextBox;
            delete label22;
            delete MinSCTextBox;
            delete label23;
            delete MaxMCTextBox;
            delete label18;
            delete MinMCTextBox;
            delete label19;
            delete MaxDCTextBox;
            delete label20;
            delete MinDCTextBox;
            delete label21;
            delete MaxMACTextBox;
            delete label16;
            delete MinMACTextBox;
            delete label17;
            delete MaxACTextBox;
            delete label15;
            delete MinACTextBox;
            delete label14;
            delete MonsterNameTextBox;
            delete label3;
            delete MonsterIndexTextBox;
            delete label1;
            delete RemoveButton;
            delete AddButton;
            delete MonsterInfoListBox;
            delete PasteMButton;
            delete CopyMButton;
            delete CoolEyeTextBox;
            delete label12;
            delete ImageComboBox;
            delete label10;
            delete ExportButton;
            delete ImportButton;
            delete ExportSelectedButton;
            delete UndeadCheckBox;
            delete AutoRevCheckBox;
            delete DropBuilderButton;
            delete fileNameLabel;
            delete label11;
        }

        Server::MirEnvir::Envir *getEnvir() const;

    private:
        std::vector<MonsterInfo*> _selectedMonsterInfos;

    public:
        MonsterInfoForm();

    private:
        void AddButton_Click(std::any sender, EventArgs *e);
        void RemoveButton_Click(std::any sender, EventArgs *e);

        void UpdateInterface();
        void RefreshMonsterList();
        void MonsterInfoListBox_SelectedIndexChanged(std::any sender, EventArgs *e);
        void MonsterNameTextBox_TextChanged(std::any sender, EventArgs *e);
        void AITextBox_TextChanged(std::any sender, EventArgs *e);
        void EffectTextBox_TextChanged(std::any sender, EventArgs *e);
        void LevelTextBox_TextChanged(std::any sender, EventArgs *e);
        void LightTextBox_TextChanged(std::any sender, EventArgs *e);
        void ViewRangeTextBox_TextChanged(std::any sender, EventArgs *e);
        void HPTextBox_TextChanged(std::any sender, EventArgs *e);
        void ExperienceTextBox_TextChanged(std::any sender, EventArgs *e);
        void MinACTextBox_TextChanged(std::any sender, EventArgs *e);
        void MaxACTextBox_TextChanged(std::any sender, EventArgs *e);
        void MinMACTextBox_TextChanged(std::any sender, EventArgs *e);
        void MaxMACTextBox_TextChanged(std::any sender, EventArgs *e);
        void MinDCTextBox_TextChanged(std::any sender, EventArgs *e);
        void MaxDCTextBox_TextChanged(std::any sender, EventArgs *e);
        void MinMCTextBox_TextChanged(std::any sender, EventArgs *e);
        void MaxMCTextBox_TextChanged(std::any sender, EventArgs *e);
        void MinSCTextBox_TextChanged(std::any sender, EventArgs *e);
        void MaxSCTextBox_TextChanged(std::any sender, EventArgs *e);
        void AccuracyTextBox_TextChanged(std::any sender, EventArgs *e);
        void AgilityTextBox_TextChanged(std::any sender, EventArgs *e);
        void ASpeedTextBox_TextChanged(std::any sender, EventArgs *e);
        void MSpeedTextBox_TextChanged(std::any sender, EventArgs *e);
        void CanPushCheckBox_CheckedChanged(std::any sender, EventArgs *e);
        void CanTameCheckBox_CheckedChanged(std::any sender, EventArgs *e);
        void AutoRevCheckBox_CheckedChanged(std::any sender, EventArgs *e);

        void UndeadCheckBox_CheckedChanged(std::any sender, EventArgs *e);
        void MonsterInfoForm_FormClosed(std::any sender, FormClosedEventArgs *e);

        void PasteMButton_Click(std::any sender, EventArgs *e);

        void CoolEyeTextBox_TextChanged(std::any sender, EventArgs *e);

        void ImageComboBox_SelectedIndexChanged(std::any sender, EventArgs *e);

        void ExportAllButton_Click(std::any sender, EventArgs *e);

        void ExportSelected_Click(std::any sender, EventArgs *e);

        void ExportMonsters(std::vector<MonsterInfo*> &monsters);

        void ImportButton_Click(std::any sender, EventArgs *e);

        void DropBuilderButton_Click(std::any sender, EventArgs *e);


        /// <summary>
        /// Required designer variable.
        /// </summary>
        System::ComponentModel::IContainer *components = nullptr;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
    protected:
        void Dispose(bool disposing) override;

        #pragma region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
    private:
        void InitializeComponent();

        #pragma endregion

        System::Windows::Forms::TabControl *tabControl1;
        System::Windows::Forms::TabPage *tabPage1;
        System::Windows::Forms::Panel *MonsterInfoPanel;
        System::Windows::Forms::CheckBox *CanTameCheckBox;
        System::Windows::Forms::CheckBox *CanPushCheckBox;
        System::Windows::Forms::TextBox *ViewRangeTextBox;
        System::Windows::Forms::Label *label33;
        System::Windows::Forms::TextBox *LightTextBox;
        System::Windows::Forms::Label *label9;
        System::Windows::Forms::TextBox *ExperienceTextBox;
        System::Windows::Forms::Label *label7;
        System::Windows::Forms::TextBox *MSpeedTextBox;
        System::Windows::Forms::Label *label6;
        System::Windows::Forms::TextBox *ASpeedTextBox;
        System::Windows::Forms::Label *label5;
        System::Windows::Forms::TextBox *LevelTextBox;
        System::Windows::Forms::Label *label4;
        System::Windows::Forms::TextBox *EffectTextBox;
        System::Windows::Forms::Label *label2;
        System::Windows::Forms::TextBox *AITextBox;
        System::Windows::Forms::Label *label8;
        System::Windows::Forms::TextBox *AgilityTextBox;
        System::Windows::Forms::Label *label26;
        System::Windows::Forms::TextBox *AccuracyTextBox;
        System::Windows::Forms::Label *label27;
        System::Windows::Forms::TextBox *HPTextBox;
        System::Windows::Forms::Label *label25;
        System::Windows::Forms::TextBox *MaxSCTextBox;
        System::Windows::Forms::Label *label22;
        System::Windows::Forms::TextBox *MinSCTextBox;
        System::Windows::Forms::Label *label23;
        System::Windows::Forms::TextBox *MaxMCTextBox;
        System::Windows::Forms::Label *label18;
        System::Windows::Forms::TextBox *MinMCTextBox;
        System::Windows::Forms::Label *label19;
        System::Windows::Forms::TextBox *MaxDCTextBox;
        System::Windows::Forms::Label *label20;
        System::Windows::Forms::TextBox *MinDCTextBox;
        System::Windows::Forms::Label *label21;
        System::Windows::Forms::TextBox *MaxMACTextBox;
        System::Windows::Forms::Label *label16;
        System::Windows::Forms::TextBox *MinMACTextBox;
        System::Windows::Forms::Label *label17;
        System::Windows::Forms::TextBox *MaxACTextBox;
        System::Windows::Forms::Label *label15;
        System::Windows::Forms::TextBox *MinACTextBox;
        System::Windows::Forms::Label *label14;
        System::Windows::Forms::TextBox *MonsterNameTextBox;
        System::Windows::Forms::Label *label3;
        System::Windows::Forms::TextBox *MonsterIndexTextBox;
        System::Windows::Forms::Label *label1;
        System::Windows::Forms::Button *RemoveButton;
        System::Windows::Forms::Button *AddButton;
        System::Windows::Forms::ListBox *MonsterInfoListBox;
        System::Windows::Forms::Button *PasteMButton;
        System::Windows::Forms::Button *CopyMButton;
        System::Windows::Forms::TextBox *CoolEyeTextBox;
        System::Windows::Forms::Label *label12;
        System::Windows::Forms::ComboBox *ImageComboBox;
        System::Windows::Forms::Label *label10;
        System::Windows::Forms::Button *ExportButton;
        System::Windows::Forms::Button *ImportButton;
        System::Windows::Forms::Button *ExportSelectedButton;
        System::Windows::Forms::CheckBox *UndeadCheckBox;
        System::Windows::Forms::CheckBox *AutoRevCheckBox;
        System::Windows::Forms::Button *DropBuilderButton;
        System::Windows::Forms::Label *fileNameLabel;
        System::Windows::Forms::Label *label11;
    };
}
